home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 August / macformat-027.iso / mac / Shareware City / Developers / Oberon⁄F / Samples / Mod / Ex3 (.txt) < prev    next >
Encoding:
Oberon Document  |  1994-06-07  |  3.8 KB  |  72 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Geneva
  16. Geneva
  17. Geneva
  18. L Frutiger Light
  19. Geneva
  20. TextRulers.StdRulerDesc
  21. TextRulers.RulerDesc
  22. TextRulers.StdStyleDesc
  23. TextRulers.StyleDesc
  24. TextRulers.AttributesDesc
  25. Geneva
  26. MODULE SamplesEx3;
  27.     IMPORT Views, TextModels, TextMappers, TextViews;
  28.         adr*: RECORD
  29.             name*:    ARRAY 64 OF CHAR;
  30.             street*:    ARRAY 64 OF CHAR;
  31.             city*:    ARRAY 24 OF CHAR;
  32.             state*:    ARRAY   6 OF CHAR;
  33.             ZIP*:    ARRAY   6 OF CHAR;
  34.             country*:    ARRAY 16 OF CHAR;
  35.             customer*:    LONGINT;
  36.             update*:    BOOLEAN;
  37.             Text*:    PROCEDURE
  38.         END;
  39.     PROCEDURE Text;
  40.         VAR t: TextModels.Model; f: TextMappers.Formatter; v: Views.View;
  41.     BEGIN
  42.         t := TextModels.dir.New();
  43.         f.ConnectTo(t);
  44.         f.WriteString(adr.name); f.WriteTab;
  45.         f.WriteString(adr.street); f.WriteTab;
  46.         f.WriteString(adr.city); f.WriteTab;
  47.         f.WriteString(adr.state); f.WriteTab;
  48.         f.WriteString(adr.ZIP); f.WriteTab;
  49.         f.WriteString(adr.country); f.WriteTab;
  50.         f.WriteInt(adr.customer); f.WriteTab;
  51.         f.WriteBool(adr.update); f.WriteLn;
  52.         v := TextViews.dir.New(t);
  53.         Views.Open(v, NIL, "")
  54.     END Text;
  55. BEGIN
  56.     adr.Text := Text
  57. END SamplesEx3.
  58. TextControllers.StdCtrlDesc
  59. TextControllers.ControllerDesc
  60. Containers.ControllerDesc
  61. Controllers.ControllerDesc
  62. Geneva
  63. Geneva
  64. Example 3
  65. This example combines some features of the previous examples: it takes the address record of the previous example, and adds behavior to it. Such a record, whose fields are displayed by controls, is called an interactor.
  66. The behavior for our example interactor is defined through the assignment of the global Text procedure to the adr.Text record field. The procedure creates a new text, into which it writes all the fields of the address record. The fields are written as one line of text, separated by tabulators and terminated by a carriage return. A new text view on this text is then opened in a window.
  67. After the example has been compiled, and after a form has been created for it and turned into a dialog, you can enter something into the fields (note that customer only accepts numeric values). Then click in the Text button. A window will be opened with a contents similar to the following:
  68. Oberon microsystems    Solothurnerstr. 45    Basel    BS    4053    Switzerland    1    $TRUE
  69. In this example, we have seen how behavior can be added to interactors, by assigning global procedures to their procedure-typed fields.
  70. Geneva
  71. Documents.ControllerDesc
  72.